<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/* ****************************************************************************
  NAIYUMIE KING WANG JJANG Front End Developer <naiyumie@gmail.com>
  FileType:CRLF, Encording:UTF-8, Tab&Space:4/4
  ------------------------------------------------------------------------
  로그인에 따른 권한 관리
  @@Todo DB화 해야함.
  @@환경변수가 개발중일때는 메시지 출력, 출시 버전일때는 리디렉션 / 404 구현
**************************************************************************** */

class NSigninChecker {

	var $CI;

    function __construct(){
        $this->CI =& get_instance();
		$this->necessaryToAdminsAuthority = array(

		);
		$this->necessaryToUsersAuthority = array(
			array('controller'=>'tmpSessionTest','method'=>'get')
		);
    }

	function userTypeCheck($t1) {

		if (!isset($this->CI->session)) {
			$this->CI->load->library('session');
		}


		$sess = $this->CI->session->all_userdata();
		foreach( $this->necessaryToUsersAuthority as $key=>$valueArray ){
			if( $valueArray['controller'] == $this->CI->uri->segment(1) && $valueArray['method'] == $this->CI->uri->segment(2) ){
				if(isset($sess['authType']) == FALSE){
					echo "<div style='color:red;border:1px solid #fe8943;background-color:#fedec7'>NSigninChecker >> 최소 유저 권한 필요</div>";
				} else {
					echo "<div style='color:green;background-color:#e7fd85;border:1px solid #9fd331;'>";
						echo "NSigninChecker >> 사용자로 패스 되었음.";
						if(isset($sess['authType'])){
							echo $sess['authType']; echo "<br>";
						}
						if(isset($sess['userName'])){
							echo $sess['userName']; echo "<br>";
						}
						if(isset($sess['dt_joined'])){
							echo $sess['dt_joined']; echo "<br>";
						}
						if(isset($sess['tm_joined'])){
							echo $sess['tm_joined']; echo "<br>";
						}
						if(isset($sess['dt_last_logined'])){
							echo $sess['dt_last_logined']; echo "<br>";
						}
						if(isset($sess['tm_last_logined'])){
							echo $sess['tm_last_logined']; echo "<br>";
						}
					echo "</div>";
				}
			} else {
				// 관리 컨트롤러가 아님.
			}
		}

		foreach( $this->necessaryToAdminsAuthority as $key=>$valueArray ){
			if( $valueArray['controller'] == $this->CI->uri->segment(1) && $valueArray['method'] == $this->CI->uri->segment(2) ){
				if(isset($sess['authType']) == FALSE){
					echo "<div style='color:red;border:1px solid #fe8943;background-color:#fedec7'>NSigninChecker >> 최소 관리자 권한 필요</div>";
				} else {
					echo "<div style='color:green;background-color:#e7fd85;border:1px solid #9fd331;'>";
						echo "NSigninChecker >> 관리자로 패스 되었음.";
						if(isset($sess['authType'])){
							echo $sess['authType']; echo "<br>";
						}
						if(isset($sess['userName'])){
							echo $sess['userName']; echo "<br>";
						}
						if(isset($sess['dt_joined'])){
							echo $sess['dt_joined']; echo "<br>";
						}
						if(isset($sess['tm_joined'])){
							echo $sess['tm_joined']; echo "<br>";
						}
						if(isset($sess['dt_last_logined'])){
							echo $sess['dt_last_logined']; echo "<br>";
						}
						if(isset($sess['tm_last_logined'])){
							echo $sess['tm_last_logined']; echo "<br>";
						}
					echo "</div>";
				}
			} else {
				// 관리 컨트롤러가 아님.
			}
		}


	}
}
/* End of file */